<%--
  Created by IntelliJ IDEA.
  User: liuxuebing
  Date: 2018/10/9
  Time: 20:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/meta.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--<div class="block_layout block_form">
    <div class="block_title">
        <h3>组合查询</h3>
        <em><a onclick="javascript:HgUi.hideShowSearch(this);" class="slide_up"></a></em>
    </div>
    <div class="block_content">
        <form id="personListForm" class="hgform">
            <table cellpadding="0" cellspacing="0" class="table_form">
                <!--普通表单填写表格使用table_form-->
                <colgroup>
                    <col style="width: 120px;" />
                    <col style="width: 120px;" />
                    <col style="width: 120px;" />
                    <col style="width: 120px;" />
                </colgroup>
                <!--表单表格宽度控制使用colgroup，每个col对应下方的一个td，或者th，上下是对齐的-->
                <thead></thead>
                <!--表头-->
                <tfoot>
                <!--表尾，主要放表单按钮-->
                <tr>
                    <th></th>
                    <td colspan="7">
                        <a href="javascript:void(0);" class="a_blue" tag="submit"><em>查询</em></a>
                        <a href="javascript:void(0);" class="a_green" tag="clear"><em>重置</em></a>
                    </td>
                </tr>
                </tfoot>
                <tbody>
                <!--表内容，th是蓝色字体，主要放字段名，td为字段内容-->
                <tr>
                    <th><span>代号:</span></th>
                    <td><input name="applyCode"/></td>
                    <th><span>姓名:</span></th>
                    <td><input name="applyCode"/></td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>--%>
<div class="easyui-layout"  data-options="fit:true" id="personView">
    <div id="personInfoWindows"></div>
    <div data-options="region:'north',border:false"
         style="padding: 0px;height: 410px">
        <table id="personList" class="easyui-datagrid" fit="true" singleSelect="true" fitColumns="true"
               url="${ctx}/person/list" toolbar="#personList_toolbar"
               title="人员列表"
               rownumbers="true" pagination="true">
            <thead>
            <tr>
                <th field="deptName" width="80">所属部门</th>
                <th field="userNum" width="80">代号</th>
                <th field="userName" width="80">姓名</th>
                <th field="carPay" width="80">车辆使用费</th>
                <th field="deductions" width="80">扣除项</th>
            </tr>
            </thead>
        </table>

        <div id="personList_toolbar" tag=listen_hotkey>
            <table class="table_form_result">
                <caption>
                    <a href="javascript:void(0);" class="a_btn_blue" tag="add"><em>新增</em></a>
                    <a href="javascript:void(0);" class="a_btn_green" tag="edit"><em>修改</em></a>
                    <a href="javascript:void(0);" class="a_btn_red" tag="del"><em>删除</em></a>
                </caption>
            </table>
        </div>
    </div>
</div>

<script type="text/javascript">
    $("#personList_toolbar").find("[tag=add]").click(function () {
        new openWindows({
            id:'personInfoWindows',
            title: '新增人员',
            width: 400,
            height: 250,
            url: '${ctx}/person/info'
        });
    });
    $("#personList_toolbar").find("[tag=edit]").click(function () {
        var row = $("#personList").datagrid("getSelected");
        if (!row){
            $.messager.alert("提示", "请选择一条记录!", "warning");
            return;
        }
        new openWindows({
            id:'personInfoWindows',
            title: '修改人员',
            width: 400,
            height: 250,
            url: '${ctx}/person/info?userId='+row.userId
        });
    });
    $("#personList").datagrid({
        //双击事件
        onDblClickRow: function (index, row) {
            $("#personList_toolbar").find("[tag=edit]").click();
        }
    });
    $("#personList_toolbar").find("[tag=del]").click(function () {
        var row = $("#personList").datagrid("getSelected");
        if (!row){
            $.messager.alert("提示", "请选择一条记录!", "warning");
            return;
        }
        $.messager.confirm('确认', '您确认要删除该条数据？', function (r) {
            if (r) {
                ajaxLoading();
                $.post("${ctx}/person/del",{id:row.userId},function (data) {
                    ajaxLoadEnd();
                    if(data.success){
                        $.messager.alert('提示','删除成功');
                        $("#personList").datagrid('reload');
                    }else {
                        $.messager.alert('提示','删除失败');
                    }
                });
            }
        });
    });
</script>
</body>
</html>
